import { UserModel } from "@/database";
/**
 * 检查登录的用户并绑定在上下文上
 */
export default defineEventHandler((event) => {

    const metaToken = getHeader(event, 'Authorization') ?? ''
    const token = metaToken.replace('Bearer ', '')
    const user = UserModel.find(item => item.id.toString() == token)
    user && (event.context.user_id = user.id)
})